home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / gnu_st.lha / gnu_st / smalltalk-1.1.1 / mstinterp.h < prev    next >
C/C++ Source or Header  |  1991-09-12  |  4KB  |  119 lines

  1. /***********************************************************************
  2.  *
  3.  *    Byte Code interpreter declarations.
  4.  *
  5.  ***********************************************************************/
  6.  
  7. /***********************************************************************
  8.  *
  9.  * Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  10.  * Written by Steve Byrne.
  11.  *
  12.  * This file is part of GNU Smalltalk.
  13.  *
  14.  * GNU Smalltalk is free software; you can redistribute it and/or modify it
  15.  * under the terms of the GNU General Public License as published by the Free
  16.  * Software Foundation; either version 1, or (at your option) any later 
  17.  * version.
  18.  * 
  19.  * GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  20.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  21.  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  22.  * more details.
  23.  * 
  24.  * You should have received a copy of the GNU General Public License along with
  25.  * GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  26.  * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  27.  *
  28.  ***********************************************************************/
  29.  
  30.  
  31. /*
  32.  *    Change Log
  33.  * ============================================================================
  34.  * Author      Date       Change 
  35.  * sbyrne     7 Jan 89      Created.
  36.  *
  37.  */
  38.  
  39.  
  40. #ifndef __MSTINTERP__
  41. #define __MSTINTERP__
  42.  
  43. #define CONTEXT_STACK_SIZE        40 /* words/OOPS in a context */
  44. #define NUM_PRIORITIES            8
  45.  
  46. /* These next three defines are the number of bits in a method header for
  47.    the number of literals, the number of temporaries, and the number of
  48.    arguments that the method takes.  If the representation is changed, these
  49.    definitions need to be altered too */
  50. #define NUM_LITERALS_BITS        6
  51. #define NUM_TEMPS_BITS            5
  52. #define NUM_ARGS_BITS            5
  53.  
  54. #define MAX_NUM_LITERALS        ((1 << NUM_LITERALS_BITS) - 1)
  55. #define MAX_NUM_TEMPS            ((1 << NUM_TEMPS_BITS) - 1)
  56. #define MAX_NUM_ARGS            ((1 << NUM_ARGS_BITS) - 1)
  57.  
  58. /*
  59. This is the organization of a method header.  The 1 bit in the high end of
  60. the word indicates that this is an integer, so that the GC won't be tempted
  61. to try to scan the contents of this field, and so we can do bitwise operations
  62. on this value to extract component pieces.
  63.  
  64.    3                   2                   1 
  65.  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  66. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  67. |1|.|.|.|.|flg| prim index    | #args   | #temps  |  #literals  |
  68. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  69.  
  70. each of args temps literals and flags could have another bit
  71.  
  72. literals 7 0..6
  73. temporarycount 5 7..11
  74. args 5 12..16
  75. primitiveIndex 8 17..24
  76. flags 2 24-25
  77. flags 0 -- use arguments as they are, ignore prim index
  78. flags 1 -- return self
  79. flags 2 -- return instance variable
  80. flags 3 -- call the primitive indexed by primIndex
  81. */
  82.  
  83. typedef struct MethodHeaderStruct {
  84. #ifdef BIG_ENDIAN
  85.   unsigned    intMark            : 1; /* flag this as an Int */
  86.   unsigned                : 5; /* unused */
  87.   unsigned    headerFlag        : 2; /* numargs, prim self, etc. */
  88.   unsigned    primitiveIndex        : 8; /* index of primitve, or 0 */
  89.   unsigned    numArgs            : NUM_ARGS_BITS;
  90.   unsigned    numTemps        : NUM_TEMPS_BITS;
  91.   unsigned    numLiterals        : NUM_LITERALS_BITS;
  92. #else
  93.   unsigned    numLiterals        : NUM_LITERALS_BITS;
  94.   unsigned    numTemps        : NUM_TEMPS_BITS;
  95.   unsigned    numArgs            : NUM_ARGS_BITS;
  96.   unsigned    primitiveIndex        : 8; /* index of primitve, or 0 */
  97.   unsigned    headerFlag        : 2; /* numargs, prim self, etc. */
  98.   unsigned                : 5; /* unused */
  99.   unsigned    intMark            : 1; /* flag this as an Int */
  100. #endif
  101. } MethodHeader;
  102.  
  103. extern OOP            methodLiteralExt(), 
  104.                 finishExecutionEnvironment();
  105. extern void            interpret(), sendMessage(), initInterpreter(),
  106.                 prepareExecutionEnvironment(), 
  107.                 storeMethodLiteralExt(), setFileStreamFile(),
  108.                 updateMethodCache(), initSignals(),
  109.                 storeMethodLiteralNoGC();
  110. extern Boolean            equal();
  111. extern long            hash();
  112. extern MethodHeader        getMethodHeaderExt();
  113.  
  114. extern long            byteCodeCounter;
  115. extern Boolean            executionTracing;
  116. extern Boolean            makeCoreFile;
  117.  
  118. #endif /* __MSTINTERP__ */
  119.